import React from "react";
import { Layout, Menu } from "antd";
import { Route, Link, Redirect } from "react-router-dom";
import MovieList from "./MovieList";
const { Content, Sider } = Layout;
const hash =
  window.location.hash.split("/").length === 2
    ? "in_theaters"
    : window.location.hash.split("/")[2];
export default class MovieContainer extends React.Component {
  constructor() {
    super();
    this.state = {};
  }
  render() {
    return (
      <Layout style={{ height: "100%" }}>
        <Sider width={200} style={{ background: "#fff" }}>
          <Menu
            mode="inline"
            defaultSelectedKeys={[hash]}
            defaultOpenKeys={["sub1"]}
            style={{ height: "100%", borderRight: 0 }}
          >
            <Menu.Item key="in_theaters">
              <Link to="/movie/in_theaters/1">正在热映</Link>
            </Menu.Item>
            <Menu.Item key="coming_soon">
              <Link to="/movie/coming_soon/1">即将上映</Link>
            </Menu.Item>
            <Menu.Item key="top250">
              <Link to="/movie/top250/1">Top250</Link>
            </Menu.Item>
          </Menu>
        </Sider>
        <Layout style={{ paddingLeft: "1px" }}>
          <Content
            style={{
              background: "#fff",
              padding: 10,
              margin: 0,
              minHeight: 280
            }}
          >
            <Route exact path="/movie" render={() => <Redirect to="/movie/in_theaters/1" />} />
            <Route path="/movie/:type/:page" component={MovieList} />
          </Content>
        </Layout>
      </Layout>
    );
  }
  componentDidMount = () => {
    this.getMovieList();
  };
  getMovieList = () => {
    // window.location.hash = "#/movie/in_theaters/1";
  };
}
